#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[2000005];

signed main() {
	int n, k, x;
	cin >> n >> k;

	queue<int> q;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	int mx = -1;
	for (int i = 1; i < k; i++) {
		q.push(a[i]);
		mx = max(mx, a[i]);
	}
	for (int i = k; i <= n; i++) {
		cout << mx << endl;
		q.pop();
		q.push(a[i]);
		mx = max(mx, a[i]);
	}
	return 0;
}
